<?php 
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
	MYDCONN();
	$MDARTICLE = 'RD';
	$GLOBALS['MYT'] = $GLOBALS['MYD'];
	if (!isset($GET[1]['Ref'])) {$GET[1]['Ref'] = $_GET['Ref']; } 
	if ($GET[1]['Ref'] == 0) {$MDARTICLE = 'ED';}  ?>
<table width="97%"  border="0" align="center" cellpadding="2" cellspacing="1" style="color:#000">
      <tr style="text-align:center" bgcolor="#FFFFFF">
        <td>CÓdigo</td>
        <td>Tipo</td>
        <td width="50%">Artigo</td>
        <td>Quant.</td>
        <td>Uso</td>
        <td>Finalidade</td>
        <td></td>
      </tr>
	<?php if($GET[1]['Ref'] == 0) { 
      echo '<tr bgcolor="#E9ECED">
        <td><input name="REFER" type="text" size="8"></td>
        <td>';
		mn_field('hselect','ED','TYPE','',"Produto;Servico;Outros#1;2;3",'','','');
		echo '</td><td>';
		mn_field('hidden',$MDARTICLE,'Article','0',"SELECT Ref, Description FROM ccenter_econ",'','','');
		mn_field('text',$MDARTICLE,'ArticleDescription','','200','50','','');
		mn_field('hidden',$MDARTICLE,'ArticleID','','','','','');
		mn_field('hidden',$MDARTICLE,'ArticleStatus','','','','','');
		mn_field('hidden',$MDARTICLE,'ArticleQuant','','','','','');
		mn_field('hidden',$MDARTICLE,'ArticleDescr','','','','','');
		mn_field('hidden',$MDARTICLE,'ArticleUse','','','','','');
		mn_field('hidden',$MDARTICLE,'ArticleUseTYPE','','','','','');
		echo '</td>
        <td>'; mn_field('text',$MDARTICLE,'Quant','1','6','6','','');
		echo '</td><td>'; mn_field('hselect',$MDARTICLE,'UseTYPE','',"Interno;Externo#1;2",'','','');
		echo '</td><td>'; mn_field('hselect',$MDARTICLE,'Use','',"Interno;Externo#1;2",'','','');
		echo '</td><td>'; mn_field('button',$MDARTICLE,'AddArticle','','','','','insert" onclick="
		document.RequestProperties.action=\'_response/rsproxy.php?act=3&pr=cdc_requests\';
		subform(\'RequestProperties\',\'respRequest\');');
		echo '</td>
		<td></td>
      </tr>';
	  }
	if ($GET[1]['Ref'] > 0) { $qrCond = ''; } else { $qrCond = '
				AND racUser = '.$_SESSION[$SESSID].'
				AND racOffice = '.$_SESSION[$SESSOF]; }
   $GETItem = $GLOBALS['MYD']->db_array("SELECT 
	ccenter_requestarticles.ref,
					ccenter_econ.REFER,
					ccenter_requestarticles.ArticleDescription AS Description,
					ccenter_econ.TYPE,
					ccenter_requestarticles.Quantity,
					ccenter_requestarticles.Status,
					ccenter_requestarticles.seTYPE,
					ccenter_requestarticles.se
				FROM ccenter_requestarticles
				LEFT OUTER JOIN ccenter_econ ON ccenter_econ.Ref = ccenter_requestarticles.RefArticle
				WHERE ccenter_requestarticles.RefRequest = {$GET[1]['Ref']} {$qrCond} 
				AND ccenter_requestarticles.Status NOT IN (5,7)"); 
	for ($a = 1; $a <= $GETItem[0]; $a++) {
	   echo '<tr bgcolor="#FFFFFF">
        <td>'.$GETItem[$a]['REFER'].'</td>
        <td>'.$GETItem[$a]['TYPE'].'</td>
        <td>';
		mn_field('text',$MDARTICLE,'Descr'.$GETItem[$a]['ref'],$GETItem[$a]['Description'],'200','50','','');
		echo '</td>
        <td>';
		mn_field('text',$MDARTICLE,'Quant'.$GETItem[$a]['ref'],round($GETItem[$a]['Quantity']),'6','6','','');
		echo '</td>
        <td>';
		$Qur = "Interno;Externo#1;2";
		mn_field('hselect',$MDARTICLE,'UseTYPE'.$GETItem[$a]['ref'],$GETItem[$a]['seTYPE'],$Qur,'','','');
		echo '</td>
        <td>';
		mn_field('hselect',$MDARTICLE,'Use'.$GETItem[$a]['ref'],$GETItem[$a]['se'],"Interno;Externo#1;2",'','','');
		echo '</td>
        <td>';
	//$Qur = "SELECT Ref AS ID, name AS NAME FROM hcce_status WHERE Type = 0";
	$Qur = "SELECT Ref AS ID, name AS NAME FROM hcce_status WHERE Ref IN (1,7)";
	mn_field('select',$MDARTICLE,'Status'.$GETItem[$a]['ref'],$GETItem[$a]['Status'],$Qur,'','',''); 
		echo '</td>
		<td>';
	if($GET[1]['Ref'] == 0) { 
		mn_field('button',$MDARTICLE,'Save','Eliminar','','','','" onClick="document.RequestProperties.action=\'_response/rsproxy.php?act=4&pr=cdc_requests&id='.$GETItem[$a]['ref'].'\';
		 subform(\'RequestProperties\',\'respRequest\');');
		}
		echo '</td>
      </tr>';
	  } ?>
    </table>